﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zive.Color {

    internal sealed class SyncRoot<T> { }

    public sealed class Singleton<T> where T: class, new( ) {

        private static T _instance;
        private static readonly SyncRoot<T> _syncRoot = new SyncRoot<T>( );

        private Singleton( ) { }

        public static T Instance {
            get {
                lock ( _syncRoot ) {
                    if ( null == _instance ) {
                        _instance = new T( );
                    }
                }

                return _instance;
            }
        }

    }

}
